#include<bits/stdc++.h>

using namespace std;

int f(int a, int n) {
    if ( a == 0 || n == 1 )return a;
    if ( n == 0 || a == 1 )return 1;
    if ( n % 2 == 0 )return f(a * a, n / 2);
    else return f(a * a, n / 2) * a;
}


int main() {
    int a = 2, n = 9;
    cout << f(a, n);

    return 0;
}
